package com.nulldev.util.analytics;

import java.util.LinkedList;

import com.nulldev.util.io.FileUtil;
import com.nulldev.util.java.JVMUtil;
import com.nulldev.util.settings.Preferences;

public class nAnalyticsSettings {

	private static final LinkedList<nAnalytics> nA = new LinkedList<nAnalytics>();
	public static final Preferences analyticsSettings = new Preferences(FileUtil.safeCreate(Preferences.HOME_DIRECTORY + "/nAnalytics-settings.cfg"));
	public static boolean allowOSFull = !JVMUtil.isArg("analytics.noOS") && !analyticsSettings.readOptionBoolean("analytics.noOS");
	public static boolean allowNetwork = !JVMUtil.isArg("analytics.noNetwork") && !analyticsSettings.readOptionBoolean("analytics.noNetwork");
	public static boolean allowUID = !JVMUtil.isArg("analytics.noUID") && !analyticsSettings.readOptionBoolean("analytics.noUID");
	public static boolean allowGPU = !JVMUtil.isArg("analytics.noGPU") && !analyticsSettings.readOptionBoolean("analytics.noGPU");
	public static boolean allowCPU = !JVMUtil.isArg("analytics.noCPU") && !analyticsSettings.readOptionBoolean("analytics.noCPU");
	
	public static boolean register(final nAnalytics na) {
		final boolean out = nA.add(na);
		if (nAnalyticsSettingsUI.get() != null) {
			nAnalyticsSettingsUI.get().updateList(nA);
		}
		return out;
	}
	
	public static LinkedList<nAnalytics> cloneList() {
		return (LinkedList<nAnalytics>) nA.clone();
	}
}
